import Router from "koa-router";
import { login, register, currentUser } from "../controller/user.controller.js";
import {
  userValidator,
  verifyUserUniqueness,
  cryptPassword,
  verifyLogin,
} from "../middleware/user.middleware.js";
import { auth } from "../middleware/auth.middleware.js";
const router = new Router({
  prefix: "/user",
});

router.post(
  "/register",
  userValidator,
  verifyUserUniqueness,
  cryptPassword,
  register
);
router.post("/login", userValidator, verifyLogin, login);
router.get("/currentUser", auth, currentUser);
// router.post("/test", auth, async (ctx, next) => {
//   ctx.body = ctx.state.user;
// });
export default router;
